const Notification = require('../models/notification');

const notificationController = {
    async getNotifications(req, res, next) {
        const { limit = 20, offset = 0 } = req.query;

        try {
            const notifications = await Notification.findByUserId(
                req.user.user_id,
                parseInt(limit),
                parseInt(offset)
            );
            res.json(notifications);
        } catch (error) {
            next(error);
        }
    },

    async markAsRead(req, res, next) {
        try {
            await Notification.markAsRead(req.params.notification_id);
            res.json({ message: 'Notification marked as read' });
        } catch (error) {
            next(error);
        }
    }
};

module.exports = notificationController;